----------------------------------------------------------------------------------------------------------------------------------
--[[

    天赋树
        self.talents = {
        ["points"] = 0, -- 当前点数 .占位符号。
        ["talent_name"] = true,
    }

    服务端监听事件 loramia_com_talent_tree_updated 来 刷新功能开启、关闭。
    客户端监听 loramia_event.talent_tree_client_side_updated 来刷新功能开启、关闭。
    
]]--
----------------------------------------------------------------------------------------------------------------------------------
local loramia_com_talent_tree = Class(function(self, inst)
    self.inst = inst

    self.talents = {}    
    ---------------------------------------------------
    --- 服务器来的数据
        inst:ListenForEvent("loramia_event.talent_tree_data_from_server", function(inst, data)
            for k, v in pairs(data or {}) do
                self.talents[k] = v
            end
            inst:PushEvent("loramia_event.talent_tree_client_side_updated")
            if TUNING.LORAMIA_DEBUGGING_MODE then
                print(" ++++++ loramia_com_talent_tree ++++++++ info ")
                print(" 天赋数据 client")
                for k, v in pairs(self.talents) do
                    print(k, v)
                end
                print(" +++++++++++++++++++++++++++++++++++++++ info ")
            end
            self:GetRPC():PushEvent("loramia_event.talent_tree_client_side_updated_for_timeout")
        end)
    ---------------------------------------------------
    
    ---------------------------------------------------
end)

------------------------------------------------------------------------------------------------------------------------------
--- RPC
    function loramia_com_talent_tree:GetRPC()
        return self.inst.replica.loramia_com_rpc_event
    end

------------------------------------------------------------------------------------------------------------------------------
--- 点数
    function loramia_com_talent_tree:GetPoints()
        local points = self.talents["points"] or 0
        return points
    end
    function loramia_com_talent_tree:IsUnlocked(index)
        if TheWorld.ismastersim then
            return self.inst.components.loramia_com_talent_tree:IsUnlocked(index)
        end
        if index == "points" or index == nil then
            return false
        end
        return self.talents[index] == true
    end
------------------------------------------------------------------------------------------------------------------------------
--- 解锁控制
    function loramia_com_talent_tree:Unlock(talent_name)
        if talent_name == "points" or talent_name == nil or self:IsUnlocked(talent_name) then
            return
        end
        self:GetRPC():PushEvent("loramia_event.talent_tree_unlock_cmd_from_client",{unlock_talent = talent_name})
    end
    function loramia_com_talent_tree:Reset()
        self:GetRPC():PushEvent("loramia_event.talent_tree_unlock_cmd_from_client",{reset = true})
    end
------------------------------------------------------------------------------------------------------------------------------
--- 打印
    function loramia_com_talent_tree:Print()
        print("+++++++++ loramia_com_talent_tree +++++++++++++")
        for k, v in pairs(self.talents) do
            print(k,v)
        end
        print("+++++++++++++++++++++++++++++++++++++++++++++++")
    end
------------------------------------------------------------------------------------------------------------------------------
return loramia_com_talent_tree







